package com.whq.thrift.api.web.admin.db.admin;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.UpdateProvider;

public interface AlertThresholdMapper {
	@Select("select * from t_alert_threshold where id=#{id}")
	@Results(value = { @Result(property = "id", column = "id"), 
			@Result(property = "type", column = "type"),
			@Result(property = "errorCode", column = "error_code"), 
			@Result(property = "minAlertThreshold", column = "min_alert_threshold"),
			@Result(property = "updateTime", column = "update_time"), 
			@Result(property = "createTime", column = "create_time")})
	public AlertThreshold getRecordByKey(@Param("id") int id);
	
	@Insert("INSERT INTO t_alert_threshold " + " (type, error_code, min_alert_threshold, create_time)"
			+ " VALUES " + " (#{type}, #{errorCode}, #{minAlertThreshold}, #{createTime})")
	@Options(useGeneratedKeys = true, keyProperty = "id")
	public void addRecord(AlertThreshold record);
	
	@SelectProvider(type = AlertThresholdSqlProvider.class, method = "getSelectRecordsSql")
	@Results(value = { @Result(property = "id", column = "id"), 
			@Result(property = "type", column = "type"),
			@Result(property = "errorCode", column = "error_code"), 
			@Result(property = "minAlertThreshold", column = "min_alert_threshold"),
			@Result(property = "updateTime", column = "update_time"), 
			@Result(property = "createTime", column = "create_time")})
	public List<AlertThreshold> findRecordsByMap(Map<String, Object> whereParams);
	
	@SelectProvider(type = AlertThresholdSqlProvider.class, method = "getSelectCountSql")
	public int findRecordsCount(Map<String, Object> whereParams);
	
	@UpdateProvider(type = AlertThresholdSqlProvider.class, method = "getUpdateSql")
	public void updRecord(AlertThreshold record);

	@Delete("delete from t_alert_threshold where id=#{id}")
	public void delRecord(@Param("id") String id);
	
	@SelectProvider(type=AlertThresholdSqlProvider.class,method="findAlertThresholdSql")
	@Results(value = { @Result(property = "id", column = "id"), 
			@Result(property = "type", column = "type"),
			@Result(property = "errorCode", column = "error_code"), 
			@Result(property = "minAlertThreshold", column = "min_alert_threshold"),
			@Result(property = "updateTime", column = "update_time"), 
			@Result(property = "createTime", column = "create_time")})
	public List<AlertThreshold> findAlertThresholdSql(Map<String, Object> whereParams);
}
